 /**
  * Функция вычисления интеграла на заданном промежутке
  * 
  */
package main;


public class runIntegral implements Runnable
{
	double x_l, x_r;
//	public Thread t;
	double stepI;
	Summ result;
	
	public runIntegral(double _xl, double _xr, double step, Summ res)
	{		
		x_l = _xl;
		x_r = _xr;
		stepI = step;
//		String str;
//		str = x_l + " " + x_r;
		result = res;
//		t = new Thread (this, str);
	}
	
	
	public void run ()
	{
		double x1, x2, x3, tmp;
		double res;
		x1=x_l;
		x2=x_r;
		res=0;
        x3=x1;
        
        while ((x2 - x3) > ( stepI/2))
        {

                x3=x1+stepI;
                tmp = (x1+x3)/2;
                res =res+ func(tmp);
                x1=x3;

        }
        result.setSumm(res);
		
		System.out.println("Интервал: "+x_l+" , "+x_r+"; Result: "+res);
			
				
	}
	
	private double func(double x)
	{
		double res;
        res = Math.sqrt(Math.abs(x))*stepI;
        return res;
	}
	
	


}


